function addUploadButton(editor){   
    CKEDITOR.on('dialogDefinition', function( ev ){   
    var dialogName = ev.data.name;
             var dialogDefinition = ev.data.definition;   
              if ( dialogName == 'image'){
                 var infoTab = dialogDefinition.getContents( 'info' );   
                  infoTab.add({
  					type : 'button',
                      id : 'upload_but',
                      align : 'center',
                      label : '上传图片1',
                      onClick : function( evt ){
                    	  var thisDialog = this.getDialog();   
                    	  var txtUrlObj = thisDialog.getContentElement('info', 'txtUrl');
                    	  var vvv = txtUrlObj.getValue();
						  var txtUrlId = txtUrlObj.getInputElement().$.id;   
						  addUploadImage(txtUrlId);
                      }
                 }, 'txtAlt'); 
            }
              else if(dialogName == 'link' ){
            	  var infoTab = dialogDefinition.getContents( 'info' );   
                  infoTab.add({
  					type : 'button',
                      id : 'upload_but',
                      align : 'center',
                      label : '上传文件1',
                      onClick : function( evt ){
                    	  var thisDialog = this.getDialog();   
                    	  var txtUrlObj = thisDialog.getContentElement('info', 'url');
                    	  var vvv = txtUrlObj.getValue();
						  var txtUrlId = txtUrlObj.getInputElement().$.id;   
						  addUploadImage(txtUrlId);
                      }
                 }, 'txtAlt'); 
              }
      });
 }
     function addUploadImage(theURLElementId){   
        var uploadUrl = "../doc/upload.jsp"; //这是我自己的处理文件/图片上传的页面URL   
         var imgUrl = window.showModalDialog(uploadUrl,null,"dialogWidth:360px;dialogHeight:120px;help:no;status:no");   
         var urlObj = document.getElementById(theURLElementId);
          urlObj.value = imgUrl;
      urlObj.fireEvent("onchange"); //触发url文本框的onchange事件，以便预览图片   
     }
     function addUploadInput(editor){   
    	    CKEDITOR.on('dialogDefinition', function( ev ){   
    	    var dialogName = ev.data.name;
    	             var dialogDefinition = ev.data.definition;   
    	              if ( dialogName == 'image' ){
    	                 var infoTab = dialogDefinition.getContents( 'info' ); 
    	                 infoTab.add(
     	    	                 {   
     		                          id : 'myUpload',   
     		                          type : 'button',   
     		                          label : '上传图片',   
     		                          style: 'height:40px',
     		                          onClick : function(){
     		                        	 ajaxFileUpload();
     		                          }
     	    	                 },'txtAlt'); 
    	                 infoTab.add(
    	                 {
	                          id : 'photo',   
	                          type : 'file',   
	                          style: 'height:40px',   
	                          size : 38
    	                 },
    	                  'txtAlt');
    	            }
    	      });
    	 }
     
     function getAjaxResult(t) {
         var _id = this.getId();
         var _doc = this.getFrameDocument();
         var num = t.listenerData;
         //获取页面返回值
         var ret = _doc.getBody().getHtml();
         //var data = eval("(" + ret + ")");
         var data = ret;
         if (data) {
                 //picurl = data.urls;
                 //CKEDITOR.tools.callFunction(num, picurl);
        	 CKEDITOR.tools.callFunction(num, data);
         } else if (data.error) {
                 CKEDITOR.tools.callFunction(num, '', '上传失败' + data.error);
         }
         this.removeListener('load', getAjaxResult);
     }